import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class InfoPage extends StatefulWidget {
  const InfoPage({super.key});

  @override
  State<InfoPage> createState() => _InfoPageState();
}

class _InfoPageState extends State<InfoPage> {
  final TextEditingController _textController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final appwith = size.width;
    final appheight = size.height;
    //输入框
    Widget myInput() {
      return Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const SizedBox(
              height: 5,
            ),
            Container(
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(5),
              ),
              child: SizedBox(
                width: appwith * 3 / 4,
                height: appwith * 3 / 4,
                child: TextFormField(
                  controller: _textController,
                  autofocus: false,
                  maxLines: null,
                  readOnly: false,
                  keyboardType: TextInputType.text,
                  style: const TextStyle(color: Colors.blue),
                  decoration: InputDecoration(
                      contentPadding: const EdgeInsets.symmetric(
                          horizontal: 20, vertical: 100),
                      //prefix: const Icon(Icons.search),
                      hintText: '输入需要发布的信息',
                      border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(5))),
                ),
              ),
            ),
            /* const SizedBox(
            width: 1,
          ), */
            ElevatedButton(
              onPressed: () {
                Fluttertoast.showToast(
                    msg: '发布成功',
                    backgroundColor: Colors.grey,
                    textColor: Colors.white,
                    fontSize: 16,
                    gravity: ToastGravity.CENTER,
                    toastLength: Toast.LENGTH_SHORT,
                    timeInSecForIosWeb: 1);
              },
              style: ButtonStyle(
                fixedSize: MaterialStateProperty.all<Size>(const Size(250, 40)),
                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                    RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0),
                )),
              ),
              child: const Text(
                '发布',
                //style: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
              ),
            )
          ],
        ),
      );
    }

    return Scaffold(
      appBar: AppBar(
        title: const Text("信息发布"),
      ),
      body: Column(
        children: [myInput()],
      ),
    );
  }
}
